package com.coderman.tianhua.idgenerator.mysql.mapper;

import org.apache.ibatis.annotations.Param;

public interface SequenceMapper {

    /**
     * 覆盖更新
     *
     * @param sequenceKey
     * @param offset
     * @return
     */
    int updateOffset(@Param("sequenceKey") String sequenceKey, @Param("offset") Long offset);

    /**
     * 查询偏移量
     *
     * @param sequenceKey
     * @return
     */
    Long selectOffsetByKey(String sequenceKey);

    /**
     * 更新偏移量，原子加操作
     *
     * @param sequenceKey
     * @param incValue
     * @return
     */
    int incOffsetByKey(@Param("sequenceKey") String sequenceKey, @Param("incValue") Long incValue, @Param("initialValue") long initialValue);

}